package apralms

class SystemFact {
		
	float failRatio = 0f
	
	float complex = 0f
	float mature = 0f
	float condition = 0f
	float workTime = 0f
	float important = 0f
	float maintain = 0f
	
	float multiplyValue = 0f

	static constraints = {
		scheme blank:false
		system blank:false
		
		failRatio min:0f, max:10f
		
		complex min:0f, max:10f
		mature min:0f, max:10f
		condition min:0f, max:10f
		workTime min:0f, max:10f
		important min:0f, max:10f
		maintain min:0f, max:10f
	}

	static belongsTo = [system:System, scheme:Scheme]
	
	def beforeInsert = {
		multiplyValue = complex * mature * condition * workTime * important * maintain
	}
	
	def beforeUpdate = {
		multiplyValue = complex * mature * condition * workTime * important * maintain
	}
	
	String toString(){
		"${system.name} - ${failRatio}"
	}
}
